<?php
namespace app\daili\controller;
use think\Controller;
use think\File;
use think\Request;

class Upload extends Base
{ 
    // ͼƬ�ϴ�
    public function upload()
    {
         
         die("兄弟你干啥呢？");
        //  if( isset( $_POST[ 'name' ] ) ) {
        //     // ���token
        //   // checkToken( $_REQUEST[ 'user_token' ], $_SESSION[ 'session_token' ], 'index.php' );
        //     $uploaded_name = $_FILES[ 'file' ][ 'name' ];
        //     $uploaded_ext  = substr( $uploaded_name, strrpos( $uploaded_name, '.' ) + 1);
        //     $uploaded_size = $_FILES[ 'file' ][ 'size' ];
        //     $uploaded_type = $_FILES[ 'file' ][ 'type' ];
        //     $uploaded_tmp  = $_FILES[ 'file' ][ 'tmp_name' ];
        //     $target_path   = 'uploads/images/';
  
        //     $target_file   =  md5( uniqid() . $uploaded_name ) . '.' . $uploaded_ext;
            
            
        //     $temp_file     = ( ( ini_get( 'upload_tmp_dir' ) == '' ) ? ( sys_get_temp_dir() ) : ( ini_get( 'upload_tmp_dir' ) ) );
        //     $temp_file    .= DIRECTORY_SEPARATOR . md5( uniqid() . $uploaded_name ) . '.' . $uploaded_ext;
        //     //�ж��Ƿ���һ��ͼƬ
        //     if( ( strtolower( $uploaded_ext ) == 'jpg' || strtolower( $uploaded_ext ) == 'jpeg' || strtolower( $uploaded_ext ) == 'png' ) &&
        //         ( $uploaded_size < 100000 ) &&
        //         ( $uploaded_type == 'image/jpeg' || $uploaded_type == 'image/png' ) &&getimagesize( $uploaded_tmp ) ) {
        //         //��������һ��ͼƬ��Ĩȥ�κο�����Σ��������
        //         if( $uploaded_type == 'image/jpeg' ) {
        //             $img = imagecreatefromjpeg( $uploaded_tmp );
        //             imagejpeg( $img, $temp_file, 100);
        //         }
        //         else {
        //             $img = imagecreatefrompng( $uploaded_tmp );
        //             imagepng( $img, $temp_file, 9);
        //         }
        //          imagedestroy( $img );
                
                
        //         // die;
        //         //�ļ�ת��
        //         if( rename( $temp_file, ( getcwd() . DIRECTORY_SEPARATOR . $target_path . $target_file ) ) ) {
        //              echo $target_file;
        //         }
        //         else {
        //              echo  '<pre>Your image was not uploaded.</pre>';
        //         }
        //         //ɾ��������ʱ�ļ�
        //         if( file_exists( $temp_file ) )
        //             unlink( $temp_file );
        //     }
        //     else {
        //         //��Ч�ļ�
        //         echo '<pre>Your image was not uploaded. We can only accept JPEG or PNG images.</pre>';
        //     }
        // }else{
        //     echo "2132123132";
        //     die;
        // }
        
    } 
    // ��Աͷ���ϴ�
    public function uploadface()
    {
      
        die("兄弟你干啥呢？");

        // if( isset( $_POST[ 'name' ] ) ) {
        //     // ���token
        //   // checkToken( $_REQUEST[ 'user_token' ], $_SESSION[ 'session_token' ], 'index.php' );
        //     $uploaded_name = $_FILES[ 'file' ][ 'name' ];
        //     $uploaded_ext  = substr( $uploaded_name, strrpos( $uploaded_name, '.' ) + 1);
        //     $uploaded_size = $_FILES[ 'file' ][ 'size' ];
        //     $uploaded_type = $_FILES[ 'file' ][ 'type' ];
        //     $uploaded_tmp  = $_FILES[ 'file' ][ 'tmp_name' ];
        //     $target_path   = 'uploads/face/';
  
        //     $target_file   =  md5( uniqid() . $uploaded_name ) . '.' . $uploaded_ext;
            
            
        //     $temp_file     = ( ( ini_get( 'upload_tmp_dir' ) == '' ) ? ( sys_get_temp_dir() ) : ( ini_get( 'upload_tmp_dir' ) ) );
        //     $temp_file    .= DIRECTORY_SEPARATOR . md5( uniqid() . $uploaded_name ) . '.' . $uploaded_ext;
        //     //�ж��Ƿ���һ��ͼƬ
        //     if( ( strtolower( $uploaded_ext ) == 'jpg' || strtolower( $uploaded_ext ) == 'jpeg' || strtolower( $uploaded_ext ) == 'png' ) &&
        //         ( $uploaded_size < 100000 ) &&
        //         ( $uploaded_type == 'image/jpeg' || $uploaded_type == 'image/png' ) &&getimagesize( $uploaded_tmp ) ) {
        //         //��������һ��ͼƬ��Ĩȥ�κο�����Σ��������
        //         if( $uploaded_type == 'image/jpeg' ) {
        //             $img = imagecreatefromjpeg( $uploaded_tmp );
        //             imagejpeg( $img, $temp_file, 100);
        //         }
        //         else {
        //             $img = imagecreatefrompng( $uploaded_tmp );
        //             imagepng( $img, $temp_file, 9);
        //         }
        //          imagedestroy( $img );
                
                
        //         // die;
        //         //�ļ�ת��
        //         if( rename( $temp_file, ( getcwd() . DIRECTORY_SEPARATOR . $target_path . $target_file ) ) ) {
        //              echo $target_path.$target_file;
        //         }
        //         else {
        //              echo  '<pre>Your image was not uploaded.</pre>';
        //         }
        //         //ɾ��������ʱ�ļ�
        //         if( file_exists( $temp_file ) )
        //             unlink( $temp_file );
        //     }
        //     else {
        //         //��Ч�ļ�
        //         echo '<pre>Your image was not uploaded. We can only accept JPEG or PNG images.</pre>';
        //     }
        // }
        
        

    }

    public function uploadshipin()
    {
         
         die("兄弟你干啥呢？");
        
        // $file = request()->file('file');
        // if (config('fbspsz') != 1)
        // {
        //     echo json_encode(['code' => 0, "msg" => "û��Ȩ��"]);
        //     exit;
        // }
        // $info = $file->move(ROOT_PATH . DS . 'uploads/shipin');

        // if ($info)
        // {
        //     echo $info->getSaveName();
        // }
        // else
        // {
        //     echo json_encode(["code" => 0, "msg" => $file->getError()]);
        // }
    }
}
